import java.util.ArrayList;
import java.util.List;

public class MovieService implements Loggable {
    private List<Movie> movieList = new ArrayList<>();

    public void addMovie(Movie movie) {
        movieList.add(movie);
        logOperation("添加影片：" + movie.getName());
    }

    public List<Movie> queryMovies(String name, String director, String actor) {
        List<Movie> result = new ArrayList<>();
        for (Movie m : movieList) {
            boolean match = true;
            if (name != null && !m.getName().toLowerCase().contains(name.toLowerCase())) {
                match = false;
            }
            if (director != null && !m.getDirector().toLowerCase().contains(director.toLowerCase())) {
                match = false;
            }
            if (actor != null && !m.getActor().toLowerCase().contains(actor.toLowerCase())) {
                match = false;
            }
            if (match) {
                result.add(m);
            }
        }
        return result;
    }

    public List<Movie> getAllMovies() {
        return movieList;
    }
}